home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1997 January / Macworld (1997-01).dmg / Shareware World / Maths & Science / DynRisk 4.0.3 / DynRisk-Help / DynRisk-Help.rsrc / TEXT_4602.txt < prev    next >
Text File  |  1996-08-30  |  5KB  |  54 lines

  1. Including events in DynRisk models
  2.  
  3. There are essentially four main categories of events:
  4.  
  5.     ‚Ä¢ ‚ÄúSend data‚Äù events
  6.     ‚Ä¢ ‚ÄúReceive data‚Äù events
  7.     ‚Ä¢ ‚ÄúSend and receive data‚Äù events
  8.     ‚Ä¢ ‚ÄúTrigger action‚Äù events
  9.  
  10. A ‚ÄúSend data‚Äù event adds all the input values it gets from its predecessors, and sends this sum to its target application. Nothing (i.e., the number zero) is passed on to its successors.
  11.  
  12. A ‚ÄúReceive data‚Äù event sends a request for a certain result (a single real number) to its target application and passes this result on to its successors.
  13.  
  14. A ‚ÄúSend and receive data‚Äù event adds all the input values it gets from its predecessors, and sends this sum together with a request for a certain result (a single real number) to its target application and passes this result on to its successors. The received result is typically some function of the input sum.
  15.  
  16. A ‚ÄúTrigger action‚Äù event simply asks its target application to carry out a certain action, e.g., recalculate a spreadsheet. Nothing (i.e., the number zero) is passed on to its successors.
  17.  
  18. When you include events in a model, a good way to start is to find out which of the above categories the different events belong to, and in which order their respective messages should be sent.
  19.  
  20. To illustrate this, we consider a simple example. Suppose you want your model to feed random numbers into a certain cell in a spreadsheet. For each such number, you want the spreadsheet to be recalculated. Finally after each recalculation, you want to transfer the value of a specific cell back to DynRisk.
  21.  
  22. As a ‚Äúrandom number generator‚Äù we use a node which we call ‚ÄúX‚Äù. The number we get back from the spreadsheet, will be passed on to a node called ‚ÄúY‚Äù.
  23.  
  24. We observe that there are three different messages we need to send to the spreadsheet: 
  25.  
  26.     ‚Ä¢ ‚ÄúSend X‚Äù
  27.     ‚Ä¢ ‚ÄúRecalculate‚Äù
  28.     ‚Ä¢ ‚ÄúReceive Y‚Äù
  29.  
  30. [If the spreadsheet is configured to do automatic recalculation, we could of course skip the second message, but for the purpose of the argument, we assume that this is not the case here. Indeed, in cases where you feed many values into a large complex spreadsheet, you may save a lot of time by switching off automatic recalculation, and then send a recalculate message after the last number has been transferred.]
  31.  
  32. To accomplish this, we will use three events, named ‚ÄúSend X‚Äù, ‚ÄúRecalculate‚Äù and ‚ÄúReceive Y‚Äù respectively. Together with the two nodes, ‚ÄúX‚Äù and ‚ÄúY‚Äù, we then have a model with five objects.
  33.  
  34. Now, to get correct results, it is obvious that the three messages need to be sent in the following order: ‚ÄúSend X‚Äù, ‚ÄúRecalculate‚Äù, ‚ÄúReceive Y‚Äù. Moreover, before we can send the value of ‚ÄúX‚Äù, we need to calculate this value, and before we can calculate ‚ÄúY‚Äù, we need to receive this value from the spreadsheet.
  35.  
  36. When DynRisk calculates a model, the model objects are always calculated in an order which respects the directions of the edges. If there is a directed path from one object to another, then the first object will always be calculated before the second.
  37.  
  38. This means that to get correct results in our case, we need to add edges to the model such that we get a directed path starting at ‚ÄúX‚Äù, passing through ‚ÄúSend X‚Äù, ‚ÄúRecalculate‚Äù and ‚ÄúReceive Y‚Äù in that order, and ending at ‚ÄúY‚Äù.
  39.  
  40. Considering the categories of the three events, we see that ‚ÄúSend X‚Äù is a ‚ÄúSend data‚Äù event, ‚ÄúRecalculate‚Äù is a ‚ÄúTrigger action‚Äù event, and ‚ÄúReceive Y‚Äù is a ‚ÄúReceive data‚Äù event. This implies that we have the following data flow through our model:
  41.  
  42.     ‚Ä¢ ‚ÄúX‚Äù -> ‚ÄúSend X‚Äù : The value of ‚ÄúX‚Äù
  43.     ‚Ä¢ ‚ÄúSend X‚Äù -> ‚ÄúRecalculate‚Äù : 0
  44.     ‚Ä¢ ‚ÄúRecalculate‚Äù -> ‚ÄúReceive Y‚Äù : 0
  45.     ‚Ä¢ ‚ÄúReceive Y‚Äù -> ‚ÄúY‚Äù : The value of ‚ÄúY‚Äù
  46.  
  47. We notice that the values passed along the two intermediate edges, are just dummy values. They are not used at all in the calculations. We still need these edges to ensure that everything happens in the right order.
  48.  
  49. Finally, note that we cannot skip ‚ÄúY‚Äù. Why? Because DynRisk does not allow events to be stored on file. Thus, we have to pass the value over to a node. 
  50.  
  51. In fact, if we skipped ‚ÄúY‚Äù in the diagram, and then tried to run a simulation on the model, then only ‚ÄúX‚Äù would be simulated. No messages will ever be sent to the spreadsheet!
  52.  
  53. In order to determine which objects that need to be calculated during a simulation, DynRisk starts out with the objects which are selected to be stored on file. If ‚ÄúY‚Äù is deleted from the model, only ‚ÄúX‚Äù could be stored. DynRisk then continues by following the edges backwards through the model, and includes all objects found along the way. In our case, ‚ÄúX‚Äù has no predecessors. Thus, without ‚ÄúY‚Äù, only ‚ÄúX‚Äù will be included in the simulation.
  54.